/*
 * Copyright (c) 2022-2022 All rights Reserved.
 */

package com.driving.core.service.dto;

import java.security.GeneralSecurityException;

import com.driving.core.base.AbstractDTO;
import com.driving.core.entity.Coach;
import com.driving.core.exception.DrivingException;
import com.driving.core.mapper.type.Gender;
import com.driving.core.util.PasswordEncryption;

import lombok.Getter;
import lombok.Setter;

/**
 * @author SAGITTAR
 * @since 2017
 */
@Getter
@Setter
public class CoachDTO extends AbstractDTO {

    private String name;

    private String mobile;

    private Gender gender;

    private String password;

    private String imagePath;

    private String correctType;

    private String oldPassword;

    public Coach toCoach() {
        Coach coach = new Coach();
        coach.setId(getId());
        coach.setName(name);
        coach.setMobile(mobile);
        coach.setGender(gender);
        try {
            coach.setPassword(PasswordEncryption.getEncryptedPassword(password));
        } catch (GeneralSecurityException e) {
            throw new DrivingException(e);
        }
        coach.setCorrectType(correctType);
        return coach;
    }
}
